// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_largeint_from_datetimev2_0_part7") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part7_7_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part7_7_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part7_7_nullable values (0, "2025-01-01 23:01:59"),(1, "2025-01-01 23:01:59"),(2, "2025-01-01 23:01:59"),(3, "2025-01-01 23:59:00"),(4, "2025-01-01 23:59:00"),(5, "2025-01-01 23:59:00"),(6, "2025-01-01 23:59:01"),(7, "2025-01-01 23:59:01"),(8, "2025-01-01 23:59:01"),(9, "2025-01-01 23:59:59"),(10, "2025-01-01 23:59:59"),(11, "2025-01-01 23:59:59"),(12, "2025-01-28 00:00:00"),(13, "2025-01-28 00:00:00"),(14, "2025-01-28 00:00:00"),(15, "2025-01-28 00:00:01"),(16, "2025-01-28 00:00:01"),(17, "2025-01-28 00:00:01"),(18, "2025-01-28 00:00:59"),(19, "2025-01-28 00:00:59"),
      (20, "2025-01-28 00:00:59"),(21, "2025-01-28 00:01:00"),(22, "2025-01-28 00:01:00"),(23, "2025-01-28 00:01:00"),(24, "2025-01-28 00:01:01"),(25, "2025-01-28 00:01:01"),(26, "2025-01-28 00:01:01"),(27, "2025-01-28 00:01:59"),(28, "2025-01-28 00:01:59"),(29, "2025-01-28 00:01:59"),(30, "2025-01-28 00:59:00"),(31, "2025-01-28 00:59:00"),(32, "2025-01-28 00:59:00"),(33, "2025-01-28 00:59:01"),(34, "2025-01-28 00:59:01"),(35, "2025-01-28 00:59:01"),(36, "2025-01-28 00:59:59"),(37, "2025-01-28 00:59:59"),(38, "2025-01-28 00:59:59"),(39, "2025-01-28 01:00:00"),
      (40, "2025-01-28 01:00:00"),(41, "2025-01-28 01:00:00"),(42, "2025-01-28 01:00:01"),(43, "2025-01-28 01:00:01"),(44, "2025-01-28 01:00:01"),(45, "2025-01-28 01:00:59"),(46, "2025-01-28 01:00:59"),(47, "2025-01-28 01:00:59"),(48, "2025-01-28 01:01:00"),(49, "2025-01-28 01:01:00"),(50, "2025-01-28 01:01:00"),(51, "2025-01-28 01:01:01"),(52, "2025-01-28 01:01:01"),(53, "2025-01-28 01:01:01"),(54, "2025-01-28 01:01:59"),(55, "2025-01-28 01:01:59"),(56, "2025-01-28 01:01:59"),(57, "2025-01-28 01:59:00"),(58, "2025-01-28 01:59:00"),(59, "2025-01-28 01:59:00"),
      (60, "2025-01-28 01:59:01"),(61, "2025-01-28 01:59:01"),(62, "2025-01-28 01:59:01"),(63, "2025-01-28 01:59:59"),(64, "2025-01-28 01:59:59"),(65, "2025-01-28 01:59:59"),(66, "2025-01-28 23:00:00"),(67, "2025-01-28 23:00:00"),(68, "2025-01-28 23:00:00"),(69, "2025-01-28 23:00:01"),(70, "2025-01-28 23:00:01"),(71, "2025-01-28 23:00:01"),(72, "2025-01-28 23:00:59"),(73, "2025-01-28 23:00:59"),(74, "2025-01-28 23:00:59"),(75, "2025-01-28 23:01:00"),(76, "2025-01-28 23:01:00"),(77, "2025-01-28 23:01:00"),(78, "2025-01-28 23:01:01"),(79, "2025-01-28 23:01:01"),
      (80, "2025-01-28 23:01:01"),(81, "2025-01-28 23:01:59"),(82, "2025-01-28 23:01:59"),(83, "2025-01-28 23:01:59"),(84, "2025-01-28 23:59:00"),(85, "2025-01-28 23:59:00"),(86, "2025-01-28 23:59:00"),(87, "2025-01-28 23:59:01"),(88, "2025-01-28 23:59:01"),(89, "2025-01-28 23:59:01"),(90, "2025-01-28 23:59:59"),(91, "2025-01-28 23:59:59"),(92, "2025-01-28 23:59:59"),(93, "2025-12-01 00:00:00"),(94, "2025-12-01 00:00:00"),(95, "2025-12-01 00:00:00"),(96, "2025-12-01 00:00:01"),(97, "2025-12-01 00:00:01"),(98, "2025-12-01 00:00:01"),(99, "2025-12-01 00:00:59"),
      (100, "2025-12-01 00:00:59"),(101, "2025-12-01 00:00:59"),(102, "2025-12-01 00:01:00"),(103, "2025-12-01 00:01:00"),(104, "2025-12-01 00:01:00"),(105, "2025-12-01 00:01:01"),(106, "2025-12-01 00:01:01"),(107, "2025-12-01 00:01:01"),(108, "2025-12-01 00:01:59"),(109, "2025-12-01 00:01:59"),(110, "2025-12-01 00:01:59"),(111, "2025-12-01 00:59:00"),(112, "2025-12-01 00:59:00"),(113, "2025-12-01 00:59:00"),(114, "2025-12-01 00:59:01"),(115, "2025-12-01 00:59:01"),(116, "2025-12-01 00:59:01"),(117, "2025-12-01 00:59:59"),(118, "2025-12-01 00:59:59"),(119, "2025-12-01 00:59:59"),
      (120, "2025-12-01 01:00:00"),(121, "2025-12-01 01:00:00"),(122, "2025-12-01 01:00:00"),(123, "2025-12-01 01:00:01"),(124, "2025-12-01 01:00:01"),(125, "2025-12-01 01:00:01"),(126, "2025-12-01 01:00:59"),(127, "2025-12-01 01:00:59"),(128, "2025-12-01 01:00:59"),(129, "2025-12-01 01:01:00"),(130, "2025-12-01 01:01:00"),(131, "2025-12-01 01:01:00"),(132, "2025-12-01 01:01:01"),(133, "2025-12-01 01:01:01"),(134, "2025-12-01 01:01:01"),(135, "2025-12-01 01:01:59"),(136, "2025-12-01 01:01:59"),(137, "2025-12-01 01:01:59"),(138, "2025-12-01 01:59:00"),(139, "2025-12-01 01:59:00"),
      (140, "2025-12-01 01:59:00"),(141, "2025-12-01 01:59:01"),(142, "2025-12-01 01:59:01"),(143, "2025-12-01 01:59:01"),(144, "2025-12-01 01:59:59"),(145, "2025-12-01 01:59:59"),(146, "2025-12-01 01:59:59"),(147, "2025-12-01 23:00:00"),(148, "2025-12-01 23:00:00"),(149, "2025-12-01 23:00:00"),(150, "2025-12-01 23:00:01"),(151, "2025-12-01 23:00:01"),(152, "2025-12-01 23:00:01"),(153, "2025-12-01 23:00:59"),(154, "2025-12-01 23:00:59"),(155, "2025-12-01 23:00:59"),(156, "2025-12-01 23:01:00"),(157, "2025-12-01 23:01:00"),(158, "2025-12-01 23:01:00"),(159, "2025-12-01 23:01:01"),
      (160, "2025-12-01 23:01:01"),(161, "2025-12-01 23:01:01"),(162, "2025-12-01 23:01:59"),(163, "2025-12-01 23:01:59"),(164, "2025-12-01 23:01:59"),(165, "2025-12-01 23:59:00"),(166, "2025-12-01 23:59:00"),(167, "2025-12-01 23:59:00"),(168, "2025-12-01 23:59:01"),(169, "2025-12-01 23:59:01"),(170, "2025-12-01 23:59:01"),(171, "2025-12-01 23:59:59"),(172, "2025-12-01 23:59:59"),(173, "2025-12-01 23:59:59"),(174, "2025-12-28 00:00:00"),(175, "2025-12-28 00:00:00"),(176, "2025-12-28 00:00:00"),(177, "2025-12-28 00:00:01"),(178, "2025-12-28 00:00:01"),(179, "2025-12-28 00:00:01"),
      (180, "2025-12-28 00:00:59"),(181, "2025-12-28 00:00:59"),(182, "2025-12-28 00:00:59"),(183, "2025-12-28 00:01:00"),(184, "2025-12-28 00:01:00"),(185, "2025-12-28 00:01:00"),(186, "2025-12-28 00:01:01"),(187, "2025-12-28 00:01:01"),(188, "2025-12-28 00:01:01"),(189, "2025-12-28 00:01:59"),(190, "2025-12-28 00:01:59"),(191, "2025-12-28 00:01:59"),(192, "2025-12-28 00:59:00"),(193, "2025-12-28 00:59:00"),(194, "2025-12-28 00:59:00")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"
    qt_sql_7_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part7_7_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_7_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part7_7_nullable order by 1;'

    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part7_7_not_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part7_7_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part7_7_not_nullable values (0, "2025-01-01 23:01:59"),(1, "2025-01-01 23:01:59"),(2, "2025-01-01 23:01:59"),(3, "2025-01-01 23:59:00"),(4, "2025-01-01 23:59:00"),(5, "2025-01-01 23:59:00"),(6, "2025-01-01 23:59:01"),(7, "2025-01-01 23:59:01"),(8, "2025-01-01 23:59:01"),(9, "2025-01-01 23:59:59"),(10, "2025-01-01 23:59:59"),(11, "2025-01-01 23:59:59"),(12, "2025-01-28 00:00:00"),(13, "2025-01-28 00:00:00"),(14, "2025-01-28 00:00:00"),(15, "2025-01-28 00:00:01"),(16, "2025-01-28 00:00:01"),(17, "2025-01-28 00:00:01"),(18, "2025-01-28 00:00:59"),(19, "2025-01-28 00:00:59"),
      (20, "2025-01-28 00:00:59"),(21, "2025-01-28 00:01:00"),(22, "2025-01-28 00:01:00"),(23, "2025-01-28 00:01:00"),(24, "2025-01-28 00:01:01"),(25, "2025-01-28 00:01:01"),(26, "2025-01-28 00:01:01"),(27, "2025-01-28 00:01:59"),(28, "2025-01-28 00:01:59"),(29, "2025-01-28 00:01:59"),(30, "2025-01-28 00:59:00"),(31, "2025-01-28 00:59:00"),(32, "2025-01-28 00:59:00"),(33, "2025-01-28 00:59:01"),(34, "2025-01-28 00:59:01"),(35, "2025-01-28 00:59:01"),(36, "2025-01-28 00:59:59"),(37, "2025-01-28 00:59:59"),(38, "2025-01-28 00:59:59"),(39, "2025-01-28 01:00:00"),
      (40, "2025-01-28 01:00:00"),(41, "2025-01-28 01:00:00"),(42, "2025-01-28 01:00:01"),(43, "2025-01-28 01:00:01"),(44, "2025-01-28 01:00:01"),(45, "2025-01-28 01:00:59"),(46, "2025-01-28 01:00:59"),(47, "2025-01-28 01:00:59"),(48, "2025-01-28 01:01:00"),(49, "2025-01-28 01:01:00"),(50, "2025-01-28 01:01:00"),(51, "2025-01-28 01:01:01"),(52, "2025-01-28 01:01:01"),(53, "2025-01-28 01:01:01"),(54, "2025-01-28 01:01:59"),(55, "2025-01-28 01:01:59"),(56, "2025-01-28 01:01:59"),(57, "2025-01-28 01:59:00"),(58, "2025-01-28 01:59:00"),(59, "2025-01-28 01:59:00"),
      (60, "2025-01-28 01:59:01"),(61, "2025-01-28 01:59:01"),(62, "2025-01-28 01:59:01"),(63, "2025-01-28 01:59:59"),(64, "2025-01-28 01:59:59"),(65, "2025-01-28 01:59:59"),(66, "2025-01-28 23:00:00"),(67, "2025-01-28 23:00:00"),(68, "2025-01-28 23:00:00"),(69, "2025-01-28 23:00:01"),(70, "2025-01-28 23:00:01"),(71, "2025-01-28 23:00:01"),(72, "2025-01-28 23:00:59"),(73, "2025-01-28 23:00:59"),(74, "2025-01-28 23:00:59"),(75, "2025-01-28 23:01:00"),(76, "2025-01-28 23:01:00"),(77, "2025-01-28 23:01:00"),(78, "2025-01-28 23:01:01"),(79, "2025-01-28 23:01:01"),
      (80, "2025-01-28 23:01:01"),(81, "2025-01-28 23:01:59"),(82, "2025-01-28 23:01:59"),(83, "2025-01-28 23:01:59"),(84, "2025-01-28 23:59:00"),(85, "2025-01-28 23:59:00"),(86, "2025-01-28 23:59:00"),(87, "2025-01-28 23:59:01"),(88, "2025-01-28 23:59:01"),(89, "2025-01-28 23:59:01"),(90, "2025-01-28 23:59:59"),(91, "2025-01-28 23:59:59"),(92, "2025-01-28 23:59:59"),(93, "2025-12-01 00:00:00"),(94, "2025-12-01 00:00:00"),(95, "2025-12-01 00:00:00"),(96, "2025-12-01 00:00:01"),(97, "2025-12-01 00:00:01"),(98, "2025-12-01 00:00:01"),(99, "2025-12-01 00:00:59"),
      (100, "2025-12-01 00:00:59"),(101, "2025-12-01 00:00:59"),(102, "2025-12-01 00:01:00"),(103, "2025-12-01 00:01:00"),(104, "2025-12-01 00:01:00"),(105, "2025-12-01 00:01:01"),(106, "2025-12-01 00:01:01"),(107, "2025-12-01 00:01:01"),(108, "2025-12-01 00:01:59"),(109, "2025-12-01 00:01:59"),(110, "2025-12-01 00:01:59"),(111, "2025-12-01 00:59:00"),(112, "2025-12-01 00:59:00"),(113, "2025-12-01 00:59:00"),(114, "2025-12-01 00:59:01"),(115, "2025-12-01 00:59:01"),(116, "2025-12-01 00:59:01"),(117, "2025-12-01 00:59:59"),(118, "2025-12-01 00:59:59"),(119, "2025-12-01 00:59:59"),
      (120, "2025-12-01 01:00:00"),(121, "2025-12-01 01:00:00"),(122, "2025-12-01 01:00:00"),(123, "2025-12-01 01:00:01"),(124, "2025-12-01 01:00:01"),(125, "2025-12-01 01:00:01"),(126, "2025-12-01 01:00:59"),(127, "2025-12-01 01:00:59"),(128, "2025-12-01 01:00:59"),(129, "2025-12-01 01:01:00"),(130, "2025-12-01 01:01:00"),(131, "2025-12-01 01:01:00"),(132, "2025-12-01 01:01:01"),(133, "2025-12-01 01:01:01"),(134, "2025-12-01 01:01:01"),(135, "2025-12-01 01:01:59"),(136, "2025-12-01 01:01:59"),(137, "2025-12-01 01:01:59"),(138, "2025-12-01 01:59:00"),(139, "2025-12-01 01:59:00"),
      (140, "2025-12-01 01:59:00"),(141, "2025-12-01 01:59:01"),(142, "2025-12-01 01:59:01"),(143, "2025-12-01 01:59:01"),(144, "2025-12-01 01:59:59"),(145, "2025-12-01 01:59:59"),(146, "2025-12-01 01:59:59"),(147, "2025-12-01 23:00:00"),(148, "2025-12-01 23:00:00"),(149, "2025-12-01 23:00:00"),(150, "2025-12-01 23:00:01"),(151, "2025-12-01 23:00:01"),(152, "2025-12-01 23:00:01"),(153, "2025-12-01 23:00:59"),(154, "2025-12-01 23:00:59"),(155, "2025-12-01 23:00:59"),(156, "2025-12-01 23:01:00"),(157, "2025-12-01 23:01:00"),(158, "2025-12-01 23:01:00"),(159, "2025-12-01 23:01:01"),
      (160, "2025-12-01 23:01:01"),(161, "2025-12-01 23:01:01"),(162, "2025-12-01 23:01:59"),(163, "2025-12-01 23:01:59"),(164, "2025-12-01 23:01:59"),(165, "2025-12-01 23:59:00"),(166, "2025-12-01 23:59:00"),(167, "2025-12-01 23:59:00"),(168, "2025-12-01 23:59:01"),(169, "2025-12-01 23:59:01"),(170, "2025-12-01 23:59:01"),(171, "2025-12-01 23:59:59"),(172, "2025-12-01 23:59:59"),(173, "2025-12-01 23:59:59"),(174, "2025-12-28 00:00:00"),(175, "2025-12-28 00:00:00"),(176, "2025-12-28 00:00:00"),(177, "2025-12-28 00:00:01"),(178, "2025-12-28 00:00:01"),(179, "2025-12-28 00:00:01"),
      (180, "2025-12-28 00:00:59"),(181, "2025-12-28 00:00:59"),(182, "2025-12-28 00:00:59"),(183, "2025-12-28 00:01:00"),(184, "2025-12-28 00:01:00"),(185, "2025-12-28 00:01:00"),(186, "2025-12-28 00:01:01"),(187, "2025-12-28 00:01:01"),(188, "2025-12-28 00:01:01"),(189, "2025-12-28 00:01:59"),(190, "2025-12-28 00:01:59"),(191, "2025-12-28 00:01:59"),(192, "2025-12-28 00:59:00"),(193, "2025-12-28 00:59:00"),(194, "2025-12-28 00:59:00");
    """

    sql "set enable_strict_cast=true;"
    qt_sql_7_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part7_7_not_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_7_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part7_7_not_nullable order by 1;'

}